//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import MebcardKK from "../../views/mall/MebcardKK.vue"
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
    gridBody: MebcardKK,
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: {
    view: [
    ], box: [], detail: []
  },//扩展的按钮
  data () {
    return {
      MebcardtypeList: [],
      rowID: ""
    }
  },
  methods: {//事件扩展
    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    onInit () {
      this.ck = false
      this.$store.getters.data().viewPageTest = this;
      let is_quota = this.getFormOption('is_quota')
      let quota = this.getFormOption('quota')
      is_quota.onChange = (v, i) => {
        if (v == 0) {
          quota.hidden = true
        } else {
          quota.hidden = false
        }
      }

      // this.openReader();

      this.columns.push(
        {
          field: '',
          title: '操作',
          type: 'int',
          fixed: 'right',
          width: 200,
          align: 'left',
          render: (h, { row, c, index }) => {
            return [
              h('el-button', {
                props: {
                  type: 'text', size: 'mini',
                  disabled: (row.memberid != "" || row.cardstatus == 5)
                },
                on: {
                  click: (e) => {
                    this.$refs.gridBody.model = true;
                    this.$refs.gridBody.KKSTATUS = false
                    this.$refs.gridBody.Mwidth = 500
                    this.$refs.gridBody.Mheight = 200
                    this.$refs.gridBody.CARDDATA = row
                    this.$nextTick(() => {
                      this.$refs.gridBody.saveCheckList = [row];
                      this.$refs.gridBody.GetVueDictionary()
                      this.$refs.gridBody.$refs.myform.reset()
                      this.$refs.gridBody.$refs.editTable1.reset()
                      this.$refs.gridBody.HYZHSTATUS = false
                    })
                  },
                }
              }, '开卡'),
              h('el-button', {
                props: {
                  type: 'text', size: 'mini',
                },
                on: {
                  click: (e) => {
                    this.$refs.gridBody.getKCL(row)
                  },
                }
              }, '卡处理'),
              h('el-button', {
                props: {
                  type: 'text', size: 'mini',
                },
                on: {
                  click: (e) => {
                    this.$refs.gridBody.modelLook = true;
                    this.$nextTick(() => {
                      this.$refs.gridBody.cardLook(row)
                    })
                  },
                }
              }, '查看'),
              h('el-button', {
                props: {
                  type: 'text', size: 'mini',
                },
                on: {
                  click: (e) => {
                    this.$refs.gridBody.modelXK = true;
                    this.$refs.gridBody.cardXK(row)
                  },
                }
              }, '写卡记录'),
            ]
          }
        }
      )
    },
    searchBefore (param) {
      let userID = JSON.parse(sessionStorage.getItem('sessionStorageUSER'))
      let wheres = [{
        name:'operatorID',
        value: `${userID.userId}`,
        displayType:'like'//设置为模糊查询,其他不需要设置
      }]

      param.wheres.push(...wheres);
      return true
    },
    wait (ms) {
      return new Promise(resolve => setTimeout(() => resolve(), ms));
    },
    // searchBefore (param) {
    //   param.order = "Asc";
    //   param.sort = "cardno";
    //   return true
    // },
    rowClick ({ row, column, event }) { //查询界面table点击行选中当前行
      this.$refs.table.$refs.table.toggleRowSelection(row);

      return true;
    },
    // 发 卡
    hairpin () {
      this.$refs.gridBody.model4 = true;
      this.$refs.gridBody.fakaUsers()
      this.$refs.gridBody.GetVueDictionary()
      this.$refs.gridBody.vc = 1
      this.$refs.gridBody.formRuleskp[0][1].hidden = false
    },
    // 开卡
    activateCcard () {
      this.$refs.gridBody.vc = 2
      this.$refs.gridBody.model = true;
      this.$refs.gridBody.KKSTATUS = true
      this.$refs.gridBody.Mwidth = 1000
      this.$refs.gridBody.Mheight = 500
      this.$nextTick(() => {
        this.$refs.gridBody.GetVueDictionary()
        this.$refs.gridBody.$refs.myform.reset()
        this.$refs.gridBody.$refs.editTable1.reset()
        this.$refs.gridBody.formRuleskp[0][1].hidden = true
      })
    },

  }
};
export default extension;
